
        .global main
        .global start
        .text
        .code 32
        .align 2

start:
          b   ResetHandle
          ldr pc,=0x30000004
          ldr pc,=0x30000008
          ldr pc,=0x3000000c
          ldr pc,=0x30000010
          nop
          bl IrqHandle
          ldr pc,=0x3000001c

ResetHandle:
      ldr r0,=0x53000000        @disable watchdog timer
      ldr r1,=0x0
      str r1,[r0]

      ldr r0,=0x4a000008        @disable all interrupt
      ldr r1,=0xffffffff
      str r1,[r0]

      ldr r0,=0x4a00001c        @disable all sub-interrupt
      ldr r1,=0x7fff
      str r1,[r0]

      @initialise system clocks
         mov    r1, #0x4c000000
          mvn   r2, #0xff000000
          str   r2, [r1]

          mov   r1, #0x4c000000

          ldr   r2, =0x5
          str   r2, [r1, #0x14]

          mrc   p15, 0, r1, c1, c0, 0           @ read ctrl register
          orr   r1, r1, #0xc0000000             @ Asynchronous
          mcr   p15, 0, r1, c1, c0, 0           @ write ctrl register

          mov   r1, #0x4c000000

          ldr   r2, =0x7f021                    @ clock user set
          str   r2, [r1, #0x4]

          @all led on
          mov r1, #0x56000000
          ldr r0,[r1,#0x10]
          orr r0,r0,#0x15400
          bic r0,r0,#0x2a800
          str r0,[r1,#0x10]

          ldr r0,[r1,#0x14]
          ldr r0,=0x67f                 @led7 and led8 are on
          str r0,[r1,#0x14]

          bl    memsetup

          mov r1, #0x56000000
          ldr r0,[r1,#0x14]
          ldr r0,=0x6ff                 @only led8 is on
          str r0,[r1,#0x14]

          mov sp,#0x33000000

          ldr   pc,=main

        @initialise the static memory

        @ set memory control registers
memsetup:
        mov     r1, #0x48000000
        adrl    r2, mem_cfg_val
        add     r3, r1, #52
l1:       ldr     r4, [r2], #4
        str     r4, [r1], #4
        cmp     r1, r3
        bne     l1
        mov     pc, lr



mem_cfg_val:
        .word 0x22111110
        .word 0x00000700
        .word 0x00000700
        .word 0x00000700
        .word 0x00000700
        .word 0x00000700
        .word 0x00000700
        .word 0x00018005
        .word 0x00018005
        .word 0x008c0459
        .word 0x31
        .word 0x30
        .word 0x30
IrqHandle:
         ldr pc, =0x30000018

        .end

